package com.rr.service.impl;

import com.rr.service.LocalCacheService;
import com.rr.util.LocalCacheHelper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.function.Function;

@Service
@RequiredArgsConstructor
public class LocalCacheServiceImpl implements LocalCacheService {

    private final LocalCacheHelper localCacheHelper;

    @Override
    public void put(String instanceName, String key, String value) {
        Function<String, String> function = s -> {
            System.out.println("调用方法获取值" + s);
            return s;
        };
        localCacheHelper.put(instanceName, key, value, 3600L, function);
    }

    @Override
    public String get(String instanceName, String key) {
        return localCacheHelper.get(instanceName, key);
    }

    @Override
    public void invalidateAll(String instanceName) {
        localCacheHelper.invalidateAll(instanceName);
    }

}
